package com.rs.service.impl.rs;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.rs.dao.AdjustmentMapper;
import com.rs.dao.UserMapper;
import com.rs.model.Adjustment;
import com.rs.model.rs.User;
import com.rs.service.rs.AdjustmentService;


@Service
public class AdjustmentServiceImpl implements AdjustmentService{

	@Autowired
	private AdjustmentMapper ad;
	@Autowired
	private UserMapper um;
	//查询所有
	@Override
	public List<Adjustment> adjustmentAllPC() {
		return ad.adjustmentAllPC();
	}
	//条件查询
	@Override
	public Adjustment adjustmentByIdPC(Adjustment adjustment) {
		return ad.adjustmentByIdPC(adjustment);
	}
	//添加申请
	@Override
	public int adjustmentAddPC(Adjustment adjustment) {
		adjustment.setAdj_audit(0);
		return ad.adjustmentAddPC(adjustment);
		 
	}
	//修改申请
	@Override
	public int adjustmentUpdatePC(Adjustment adjustment) {
		adjustment.setAdj_audit(0);
		return ad.adjustmentUpdatePC(adjustment);
	}
	//删除申请
	@Override
	public int adjustmentDelPC(Adjustment adjustment) {
		return ad.adjustmentDelPC(adjustment);
		
	}
	
	
	
	
	
	
	//App查询
	@Override
	public List adjustmentAllApp() {
		return ad.adjustmentAllApp();
	}
	//App添加
	@Override
	public int adjustmentAddApp(Adjustment adjustment) {
		adjustment.setAdj_audit(0);
		return ad.adjustmentAddApp(adjustment);
		
	}
	//App修改
	@Override
	public int adjustmentUpdateApp(Adjustment adjustment) {
		adjustment.setAdj_audit(0);
		return ad.adjustmentUpdateApp(adjustment);
		
	}
	//App删除
	@Override
	public int adjustmentDelApp(Adjustment adjustment) {
		return ad.adjustmentDelApp(adjustment);
	}
	
	@Override
	public List<Adjustment> adjustmentAll() {
		return ad.adjustmentAll();
	}
	//审核
	@Override
	public void adjustmentToExamine(Adjustment adjustment) {
		
		User uu = new User();
		if(adjustment.getAdj_audit() == 2) {
			ad.adjustmentUpdateApp(adjustment);
			return;
		}else if(adjustment.getAdj_audit() == 1){
			ad.adjustmentUpdateApp(adjustment);
			uu.setU_id(adjustment.getAdj_uid());
			uu.setU_poid(adjustment.getAdj_newpoid());
			uu.setU_deid(adjustment.getAdj_newdeid());
			um.userChangeInfoApp(uu);
		}
		
	}
}
